//
//  BaseTableController.m
//  oc1
//
//  Created by kokuma on 2017/2/10.
//  Copyright © 2017年 kokumams. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BaseTableController.h"
#import "NSObject+Common.h"

@interface BaseTableController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation BaseTableController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //    添加myTableView
    _myTableView = ({
        UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
        tableView.dataSource = self;
        tableView.delegate = self;
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        // [self.view addSubview:tableView];
        //        [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        //            make.edges.equalTo(self.view);
        //        }];
        tableView;
    });
    [self setupCells];
    [self.view addSubview:_myTableView];
    [self getDataList];
}

//需要重载的方法
- (void)setupCells{
    //[tableView registerClass:[ConversationCell class] forCellReuseIdentifier:kCellIdentifier_Conversation];
}

//需要重载的方法
- (void)getDataList{
    printf("testAFNetworking1");
    MPNetAPIManager *netAPI = [MPNetAPIManager sharedManager];
    [netAPI getRecommendUsers:@"1" andBlock:^(id data, NSError *error) {
        if(data){
            NSMutableArray *accounts = data;
            if(!_dataList){
                _dataList = [NSMutableArray new];
            }
            [_dataList removeAllObjects];
            for(id openA in accounts){
//                OpenAccountBean *bean = [[OpenAccountBean alloc] initWithDictionary:openA];
//                NSLog(bean.displayName);
//                NSLog([@(bean.id.longValue) stringValue]);
//                [_dataList addObject:bean];
            }
            [_myTableView reloadData];
        }
    }];
}

//需要重载的方法
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return nil;
}

//需要重载的方法
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return  60;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if(_dataList){
        return _dataList.count;
    }else{
        return 0;
    }
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];// 取消选中
    //其他代码
    [self tappedFollow:indexPath];
}

-(void)tappedFollow:(NSIndexPath *)indexPath{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end